package t04;

import java.net.MalformedURLException;
import java.net.URL;

public class AnalyseURL {
    public static void main(String[] args) {
        String urlString = "https://baidu.com:8080/system/login.jsp?user=admin&password=123#top";
        try {
            URL url = new URL(urlString);
            System.out.println("协议：" + url.getProtocol());
            System.out.println("主机：" + url.getHost());
            System.out.println("端口：" + url.getPort());
            System.out.println("路径：" + url.getPath());
            System.out.println("参数：" + url.getQuery());
            System.out.println("引用：" + url.getRef());
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }

    }
}
